import request from '@/router/axios';
import {baseUrl} from "../../config/env";

export const getList = (current, size, params) => {
  return request({
    url:  baseUrl + '/api-job/joblog/newList',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  })
}

export const getDetail = (id) => {
  return request({
    url: baseUrl + '/api-job/jobinfo/detail/'+id,
    method: 'get',
    // params: {
    //   id
    // }
  })
}

export const remove = (ids) => {
  return request({
    url: baseUrl + '/api-job/jobgroup/newremove',
    method: 'post',
    params: {
      ids,
    }
  })
}

export const add = (row) => {
  return request({
    url: baseUrl + '/api-job/jobgroup/newsave',
    method: 'post',
    data: row
  })
}

export const update = (row) => {
  return request({
    url: baseUrl + '/api-job/jobgroup/newupdate',
    method: 'post',
    data: row
  })
}


export const trigger = (id,executorParam,jobGroup) => {
  return request({
    url: baseUrl + '/api-job/jobinfo/newtrigger',
    method: 'post',
    data: {
      id,
      executorParam,
      jobGroup
    }
  })
}

export const getRegister = (id) => {
  return request({
    url: baseUrl + '/api-job/jobgroup/detail/'+id,
    method: 'get',
    // params: {
    //   id
    // }
  })
}
export const getNextExecTime = (type, conf) => {
  return request({
    url: baseUrl + '/api-job/jobinfo/nextTriggerTime',
    method: 'post',
    data: {
      scheduleType: type,
      scheduleConf: conf
    }
  })
}

export const taskStart = (id) => {
  return request({
    url: baseUrl + '/api-job/jobinfo/newstart',
    method: 'post',
    data: {
      id
    }
  })
}

export const taskStop = (id) => {
  return request({
    url: baseUrl + '/api-jobn/jobinfo/newstop',
    method: 'post',
    data: {
      id
    }
  })
}
